package com.woniu.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.dsna.util.images.ValidateCode;

/**
 * Servlet implementation class CheckCodeServlet
 */
@WebServlet("/CheckCodeServlet")
public class CheckCodeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CheckCodeServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		String vode = request.getParameter("checknum");
//		System.out.println("vode:\t"+vode);
		response.setHeader("param", "no-cache");
		response.setHeader("cache-control","no-cache");
		response.setIntHeader("expires",0);
		ValidateCode vc = new ValidateCode(120,40,4,12);
		String code = vc.getCode();
		HttpSession session = request.getSession();
//		request.setAttribute("gode", vode);
//		request.setAttribute("vode",code);
//		response.sendRedirect("CodeServlet");
		vc.write(response.getOutputStream());
		
//		 request.setAttribute("code", code);
		
		
		//response.getWriter().write(""+result);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
